$(function(){
	
	var $btnAdd = $('#btnAdd');
	$btnAdd.click(function(){
		goodsAdd();
	});
	
});

//添加商品
function goodsAdd(){
	
	var $cate_id	= $('#cate_id');
	var $name		= $('#name');
	var $ename		= $('#ename');
	var $edescribe	= $('#edescribe');
	var $describe	= $('#describe');
	var $story		= $('#story');
	var $detail		= $('#detail');
	var $tips		= $('#tips');
	var $price		= $('#price');
	var $unit		= $('#unit');
	var $ord		= $('#ord');
	var $image		= $('#image');
	
 
	var cate_id	= $cate_id.val();
	var name	= $name.val();
	var ename	= $ename.val();
	var edescribe= $edescribe.val();
	var describe= $describe.val();
	var story	= $story.val();
	var detail	= editor.getData();
	var tips	= $tips.val();
	var price	= $price.val();
	var unit	= $unit.val();
	var ord		= $ord.val();
	var is_recommend	= $('input[name="is_recommend"]:checked').val();
	var is_star			= $('input[name="is_star"]:checked').val();
	var is_cart			= $('input[name="is_cart"]:checked').val();
	var image	= $image.val();

	var is_hot				= $('#is_hot:checked').val();
	var is_birth			= $('#is_birth:checked').val();
	var is_children			= $('#is_children:checked').val();
	var is_lover			= $('#is_lover:checked').val();	
	var is_party			= $('#is_party:checked').val();
	var is_afternoon_tea	= $('#is_afternoon_tea:checked').val();
	var is_wedding			= $('#is_wedding:checked').val();
	var is_celebration		= $('#is_celebration:checked').val();
	
	if(is_hot != undefined){
		is_hot = 1;
	}else{
		is_hot = 0;
	}
	
	if(is_birth != undefined){
		is_birth = 1;
	}else{
		is_birth = 0;
	}

	if(is_children != undefined){
		is_children = 1;
	}else{
		is_children = 0;
	}	
	
	if(is_lover != undefined){
		is_lover = 1;
	}else{
		is_lover = 0;
	}
	
	if(is_party != undefined){
		is_party = 1;
	}else{
		is_party = 0;
	}
	
	if(is_afternoon_tea != undefined){
		is_afternoon_tea = 1;
	}else{
		is_afternoon_tea = 0;
	}
	
	if(is_wedding != undefined){
		is_wedding = 1;
	}else{
		is_wedding = 0;
	}
	
	if(is_celebration != undefined){
		is_celebration = 1;
	}else{
		is_celebration = 0;
	}
	
	var params = {
		'cate_id'	: cate_id,
		'name'		: name,
		'ename'		: ename,
		'edescribe'	: edescribe,
		'describe'	: describe,
		'story'		: story,
		'detail'	: detail,
		'tips'		: tips,
		'price'		: price,
		'unit'		: unit,
		'ord'		: ord,
		'is_recommend':is_recommend,
		'is_star'	: is_star,
		'is_cart'	: is_cart,
		'image'		: image,
		'is_hot'			: is_hot,
		'is_birth'			: is_birth,
		'is_children'		: is_children,
		'is_lover'			: is_lover,
		'is_party'			: is_party,
		'is_afternoon_tea'	: is_afternoon_tea,
		'is_wedding'		: is_wedding,
		'is_celebration'	: is_celebration
	};
	
	$.post('/index.php/Admin/Goods/add_do',params,function(data){
		if(data.success){
			alert('商品添加成功');
			location.reload(true);
		}else{
			alert('商品添加失败');
		}
	},'json');


}